package com.hsylient.javase.chapter02.demo01.demo03;

/**
 * static字段和static方法
 */
public class Student {
    private String name;
    private int id;
    private static int nextId = 1;

    public Student(String name) {
        this.name = name;
    }

    public void setId() {
        this.id = nextId;
        nextId++;
    }

    public static void eatFood() {
        System.out.println("吃饭。。。。");
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", id=" + id +
                '}';
    }
}
